﻿@model blacksoft.Models.Ruta
@using blacksoft.Helpers
@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    ViewBag.Title = "Rutas";
}

@if (TempData["edit"] != null)
{
    <div class="error grid_12">
        <h3>Error: @TempData["edit"]</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}

<div class="block big">
    <div class="titlebar">
        <h3>Modificar Ruta</h3>
    </div>

    <div class="block_cont">

        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()

            <div class="form">
                @Html.ValidationSummary(true)
                @Html.HiddenFor(model => model.IDRuta)
                @Html.HiddenFor(model => model.IDTerminal)

                <div class="form-group">
                    @Html.LabelForRequired(model => model.Origen)
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.Origen, new { @class = "text-box single-line", @readonly = "readonly", @disabled = "disabled" })
                        @Html.HiddenFor(model => model.Origen)
                        @Html.ValidationMessageFor(model => model.Origen)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.TerminalOrigen)
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.TerminalOrigen, new { @class = "text-box single-line", @readonly = "readonly", @disabled = "disabled" })
                        @Html.HiddenFor(model => model.TerminalOrigen)
                        @Html.ValidationMessageFor(model => model.TerminalOrigen)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.Destino)
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.Destino, new { @class = "text-box single-line", @readonly = "readonly", @disabled = "disabled" })
                        @Html.HiddenFor(model => model.Destino)
                        @Html.ValidationMessageFor(model => model.Destino)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.TerminalDestino)
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.TerminalDestino, new { @class = "text-box single-line", @readonly = "readonly", @disabled = "disabled" })
                        @Html.HiddenFor(model => model.TerminalDestino)
                        @Html.ValidationMessageFor(model => model.TerminalDestino)
                    </div>
                </div>

                <br />
                <div class="titlebar">
                    <h3>@Html.DisplayNameFor(model => model.Escala)</h3>
                </div>
                <div class="block_cont">
                    <table class="table">
                        <tr>
                            <th width="20">
                                <input type="checkbox" name="check" value=""></input>
                            </th>
                            <th>Duración</th>
                            <th>Núm. Secuencia</th>
                        </tr>
                        @{
                            List<blacksoft.Models.EscalaAsignada> escalas = ViewBag.Escalas;

                            foreach (var item in escalas)
                            {
                                @:<tr>
                                @:<td>
                                    <input type="checkbox" name="escalas" value="@item.IDTerminal" @Html.Raw(item.Asignado ? "checked=\"checked\"" : "") />
                                    @item.IDTerminal @:  @item.Nombre
                                @:</td>
                                @:<td>
                                    <input type="text" name="duracion" value="@item.Duracion" class="text-box single-line" } />
                                @:</td>
                                @:<td>
                                    <input type="text" name="secuencia" value="@item.NumeroSecuencia" class="text-box single-line" } />
                                @:</td>
                                @:</tr>
                            }
                        }
                    </table>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.TiempoViaje)
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.TiempoViaje)
                        @Html.ValidationMessageFor(model => model.TiempoViaje)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.Distancia)
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Distancia)
                        <text>km</text>
                        @Html.ValidationMessageFor(model => model.Distancia)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.Estado)
                    <div class="col-md-10">
                        @Html.DropDownList("Estado", new[]
                {
                    new SelectListItem() {Text = "Activo", Value="AC"},
                    new SelectListItem() {Text = "Inactivo", Value="IN"},
                    new SelectListItem() {Text = "Anulado", Value="AN"},
                }, new { @class = "select" })
                        @Html.ValidationMessageFor(model => model.Estado)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelForRequired(model => model.PuntosAGanar)
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.PuntosAGanar)
                        <text>por km</text>
                        @Html.ValidationMessageFor(model => model.PuntosAGanar)
                    </div>
                </div>
                <br />
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Guardar" class="btn btn-default" />
                    </div>
                </div>
            </div>
        }

        </br>
        <p>
            @Html.ActionLink("Regresar al listado", "Index")
        </p>
    </div>
</div>